package com.yu.xcx.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yu.xcx.dto.Result;
import com.yu.xcx.entity.BlogComments;
import com.yu.xcx.entity.Shop;
import com.yu.xcx.mapper.BlogCommentsMapper;
import com.yu.xcx.service.IBlogCommentsService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlogCommentsServiceImpl extends ServiceImpl<BlogCommentsMapper, BlogComments> implements IBlogCommentsService {


    @Override
    public Boolean saveBlogComments(BlogComments blogComments) {
        return save(blogComments);
    }

    @Override
    public Result queryByShopId(Integer shopId) {

        Page<BlogComments> page = query()
                .eq("shop_id",shopId)
                .page(new Page<>(1, 8));
        List<BlogComments> BlogsList = page.getRecords();

        return Result.ok(BlogsList);
    }

    @Override
    public Result queryByParentId(Integer parentId) {
        Page<BlogComments> page = query()
                .eq("parent_id",parentId)
                .page(new Page<>(1, 8));
        List<BlogComments> BlogsList = page.getRecords();

        return Result.ok(BlogsList);
    }
}
